//
//  ERPersonalDataVC.m
//  EnjoyRunning
//
//  Created by ljm on 2017/4/19.
//  Copyright © 2017年 ljm. All rights reserved.
//

#import "ERPersonalDataVC.h"

@interface ERPersonalDataVC ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong) UITableView *myTableView;

@end

@implementation ERPersonalDataVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}

- (void)setupUI
{
    self.view.backgroundColor = rootVC.view.backgroundColor;
    self.myTableView.backgroundColor = rootVC.view.backgroundColor;
    [self.view addSubview:self.myTableView];
}

#pragma mark -- datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    switch (section) {
        case 0:
            return 1;
            break;
        case 1:
            return 2;
            break;
        default:
            return 4;
            break;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.000001;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 60;
    }else{
        return 50;
    }
}

#pragma mark -- tableview delegate
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"myCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:
                UITableViewCellStyleSubtitle reuseIdentifier:identifier];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    switch (indexPath.section) {
        case 0:
           {
                cell.textLabel.text = @"头像";
               UIImageView *iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
               iconImage.center = CGPointMake(cell.frame.size.width * 0.8, cell.frame.origin.y + 30);
               iconImage.image = [UIImage imageNamed:@"mine_normal"];
               [cell addSubview:iconImage];
           }
            
            break;
            
        case 1:
        {
            if (indexPath.row == 0) {
                cell.textLabel.text = @"昵称";
                
                UILabel *userNameLab = [[UILabel alloc] initWithFrame:
                                        CGRectMake(
                                                   0, 0, kwidth * 0.3, 30)];
                userNameLab.center = CGPointMake(
                                                 kwidth * 0.8, cell.frame.origin.y + 25);
                userNameLab.text = @"享跑者123456";
                userNameLab.textColor = [UIColor grayColor];
                userNameLab.textAlignment = NSTextAlignmentCenter;
                userNameLab.font = AAFont(25);
                [cell addSubview:userNameLab];
//                cell.detailTextLabel.text = @"享跑者123456";
            }else{
                cell.textLabel.text = @"二维码";
//                cell.imageView.image = [UIImage imageNamed:@"mine_select"];
                
                UIImageView *iconImage = [[UIImageView alloc] initWithFrame:
                                          CGRectMake(
                                                     0, 0, 30, 30)];
                iconImage.center = CGPointMake(
                                               cell.frame.size.width * 0.8, cell.frame.origin.y + cell.frame.size.height/2);
                iconImage.image = [UIImage imageNamed:@"mine_normal"];
                [cell addSubview:iconImage];
            }
        }
            break;
            
        default:
            switch (indexPath.row) {
                case 0:
                {
                    cell.textLabel.text = @"性别";
//                    cell.detailTextLabel.text = @"女";
                    UILabel *sexLab = [[UILabel alloc] initWithFrame:
                                       CGRectMake(0, 0, kwidth * 0.3, 30)];
                    sexLab.center = CGPointMake(
                                                kwidth * 0.8, cell.frame.origin.y + 25);
                    sexLab.text = @"女";
                    sexLab.textColor = [UIColor grayColor];
                    sexLab.textAlignment = NSTextAlignmentCenter;
                    sexLab.font = AAFont(25);
                    [cell addSubview:sexLab];
                }
                    break;
                case 1:
                {
                    cell.textLabel.text = @"年龄";
//                    cell.detailTextLabel.text = @"23";
                    UILabel *ageLab = [[UILabel alloc] initWithFrame:
                                       CGRectMake(
                                                  0, 0, kwidth * 0.3, 30)];
                    ageLab.center = CGPointMake(
                                                kwidth * 0.8, cell.frame.origin.y + 25);
                    ageLab.text = @"23";
                    ageLab.textColor = [UIColor grayColor];
                    ageLab.textAlignment = NSTextAlignmentCenter;
                    ageLab.font = AAFont(25);
                    [cell addSubview:ageLab];
                }
                    break;
                case 2:
                {
                    cell.textLabel.text = @"身高";
//                    cell.detailTextLabel.text = @"168.cm";
                    UILabel *heightLab = [[UILabel alloc] initWithFrame:
                                          CGRectMake(
                                                     0, 0, kwidth * 0.3, 30)];
                    heightLab.center = CGPointMake(kwidth * 0.8, cell.frame.origin.y + 25);
                    heightLab.text = @"177.cm";
                    heightLab.textColor = [UIColor grayColor];
                    heightLab.textAlignment = NSTextAlignmentCenter;
                    heightLab.font = AAFont(25);
                    [cell addSubview:heightLab];
                }
                    break;
                default:
                {
                    cell.textLabel.text = @"体重";
//                    cell.detailTextLabel.text = @"45.kg";
                    UILabel *weightLab = [[UILabel alloc] initWithFrame:
                                          CGRectMake(
                                                     0, 0, kwidth * 0.3, 30)];
                    weightLab.center = CGPointMake(
                                                   kwidth * 0.8, cell.frame.origin.y + 25);
                    weightLab.text = @"75.kg";
                    weightLab.textColor = [UIColor grayColor];
                    weightLab.textAlignment = NSTextAlignmentCenter;
                    weightLab.font = AAFont(25);
                    [cell addSubview:weightLab];
                }
                    break;
            }
            break;
    }
    
    return cell;
}

#pragma mark -- getter
- (UITableView *)myTableView
{
    if (!_myTableView) {
        _myTableView = [[UITableView alloc] initWithFrame:
                        CGRectMake(
                                   0, 64, kwidth, kheight * 0.8)
                                                    style:UITableViewStyleGrouped];
        _myTableView.delegate = self;
        _myTableView.dataSource = self;
    }
    return _myTableView;
}

@end
